public class Graph
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private java.util.ArrayList<Edge> |
edgeList
The list of edges added to the graph.
|
private java.lang.String |
graphName
The name of the Graph provided by the user.
|
private java.util.ArrayList<Node> |
nodeList
The list of the nodes added to the graph.
|
protected boolean |
suppressLog
Used to suppress logging.
|
| Modifier | Constructor and Description |
|---|---|
|
Graph(java.lang.String graphName)
Initializes the graph.
|
protected |
Graph(java.lang.String graphName,
java.util.ArrayList<Node> nodeList,
java.util.ArrayList<Edge> edgeList)
Private constructor used by subGraph method.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
addEdge(Edge edge)
Adds an edge to the Graph.
|
boolean |
addEdge(int node1Index,
int node2Index,
java.lang.Object edgeData)
Deprecated.
Outdated since v3. Replaced by
{}
|
boolean |
addEdge(java.lang.String node1,
java.lang.String node2,
java.lang.Object edgeData)
Deprecated.
Outdated since v3. Replaced by
{
|
boolean |
addEdges(java.util.List<Edge> edges)
Adds a list of Edges to the graph.
|
boolean |
addNewNode(java.lang.String node)
Deprecated.
Outdated since v3. Replaced by
{}
|
boolean |
addNode(Node node)
Adds a node to the graph.
|
boolean |
addNodes(java.util.List<Node> nodes)
Adds a list of nodes to the graph.
|
boolean |
addPartialGraph(java.util.List<Node> nodes,
java.util.List<Edge> edges)
Adds a partial graph to this graph.
|
private void |
checkNode(Node node)
Verifies that the node is NOT in the graph.
|
private void |
checkNodeIndex(int nodeIndex)
Deprecated.
No replacement. Further operations shall utilize
{)}
|
Graph |
copy()
Copies this Graph object using the getSubGraph() method.
|
java.util.List<Node> |
getAdjacencyList(Node node)
Obtains an adjacency list for the supplied node based on the Graph.
|
java.lang.Object |
getEdge(int node1Index,
int node2Index)
Deprecated.
Outdated since v3. No replacement. Obtain the edge first,
then obtain the data from the Edge object.
|
Edge |
getEdge(Node source,
Node destination)
Locates an Edge object in the edgeList and returns it.
|
java.lang.Object |
getEdge(java.lang.String node1,
java.lang.String node2)
Deprecated.
Outdated since v3. No replacement. Obtain the edge first,
then obtain the data from the Edge object.
|
java.util.List<Edge> |
getEdgeList()
Returns the list of edges in the graph.
|
java.lang.String |
getName()
Gets the name of the graph.
|
int |
getNodeCount()
Gets the number of nodes in the graph.
|
int |
getNodeIndex(Node node)
Gets the index of a Node object in memory.
|
int |
getNodeIndex(java.lang.String node)
Deprecated.
Outdated since v3. Replaced by
{}
|
java.util.List<Node> |
getNodeList()
Returns the list of nodes in the graph.
|
java.lang.String |
getNodeName(int nodeIndex)
Deprecated.
Outdated since v3. No replacement. Obtain the Node data via
the
Node object. |
Graph |
getSubGraph(java.util.ArrayList<java.lang.String> subStringSet,
java.lang.String nameQualifier)
Deprecated.
Outdated since v3. Replaced by
getSubGraph(java.util.List, java.lang.String) |
Graph |
getSubGraph(int startNode,
int stopNode,
java.lang.String nameQualifier)
Deprecated.
Outdated since v3. Replaced by
getSubGraph(java.util.List, java.lang.String) |
Graph |
getSubGraph(java.util.List<Node> nodes,
java.lang.String nameQualifier)
Returns a subGraph of this graph.
|
void |
transpose(int node1Index,
int node2Index)
Transposes the specified nodes.
|
void |
transpose(Node node1,
Node node2)
Transposes the specified nodes.
|
void |
transpose(java.lang.String node1,
java.lang.String node2)
Deprecated.
Outdated since v3. Replaced by
{}
|
Graph |
uniqueCopy()
Copies this Graph producing a unique copy in which there is no
entanglement between the two Graph objects.
|
private final java.lang.String graphName
private final java.util.ArrayList<Node> nodeList
private final java.util.ArrayList<Edge> edgeList
protected boolean suppressLog
public Graph(java.lang.String graphName)
graphName - the String which represents the name of the Graph.protected Graph(java.lang.String graphName,
java.util.ArrayList<Node> nodeList,
java.util.ArrayList<Edge> edgeList)
graphName - the String which represents the name of the Graph.nodeList - the ArrayList of Node objects.edgeList - the ArrayList of Edge objects.public java.lang.String getName()
public boolean addNewNode(java.lang.String node)
node - the String which denotes the name of the node to add.public boolean addNode(Node node)
node - the Node object to add.public boolean addNodes(java.util.List<Node> nodes)
nodes - the List<Node> containing the nodes to add.public int getNodeIndex(java.lang.String node)
node - the String representing the node to search for.public int getNodeIndex(Node node)
node - the Node object to search for.public int getNodeCount()
public java.lang.String getNodeName(int nodeIndex)
Node object.nodeIndex - the integer representing the index to get from the
headerList.public java.util.List<Node> getNodeList()
public boolean addEdge(int node1Index,
int node2Index,
java.lang.Object edgeData)
node1Index - the integer value indicating the first node.node2Index - the integer value indicating the second node.edgeData - the Object that represents unique edge data (i.e. weight
or edge relationship).public boolean addEdge(java.lang.String node1,
java.lang.String node2,
java.lang.Object edgeData)
node1 - the String indicating the first node.node2 - the String indicating the second node.edgeData - the Object that represents unique edge data (i.e. weight
or edge relationship).public boolean addEdge(Edge edge)
edge - the Edge object to add to the graph.public boolean addEdges(java.util.List<Edge> edges)
edges - the List<Edge> containing the edges to add.public java.lang.Object getEdge(int node1Index,
int node2Index)
node1Index - the integer value of the first node.node2Index - the integer value of the second node.public java.lang.Object getEdge(java.lang.String node1,
java.lang.String node2)
node1 - the String of the first node.node2 - the String of the second node.public Edge getEdge(Node source, Node destination)
source - the source Node of the edge.destination - the destination Node of the edge.public java.util.List<Edge> getEdgeList()
public boolean addPartialGraph(java.util.List<Node> nodes, java.util.List<Edge> edges)
nodes - the List<Node> containing the nodes to add.edges - the List<Edge> containing the edges to add.public Graph getSubGraph(int startNode, int stopNode, java.lang.String nameQualifier)
getSubGraph(java.util.List, java.lang.String)startNode - the integer pointing to the start node.stopNode - the integer pointing to the stop node.nameQualifier - the String representing an additional qualifier to
prepend the name of the new Graph object with.public Graph getSubGraph(java.util.ArrayList<java.lang.String> subStringSet, java.lang.String nameQualifier)
getSubGraph(java.util.List, java.lang.String)subStringSet - an ArrayList containing the String names of the desired nodes.nameQualifier - the String representing an additional qualifier to
prepend the name of the new Graph object with.public Graph getSubGraph(java.util.List<Node> nodes, java.lang.String nameQualifier)
nodes - the List<Node> containing the Node references.nameQualifier - the String to differentiate the Graph names.public void transpose(int node1Index,
int node2Index)
node1Index - the integer index of the first node.node2Index - the integer index of the second node.public void transpose(java.lang.String node1,
java.lang.String node2)
node1 - the String name of the first node.node2 - the String name of the second node.public void transpose(Node node1, Node node2)
node1 - the Node object in the first position.node2 - the Node object in the second position.public java.util.List<Node> getAdjacencyList(Node node)
node - the Node to obtain the adjacency list for.private void checkNode(Node node)
node - the Node to check for.private void checkNodeIndex(int nodeIndex)
nodeIndex - the integer of the node to check for.public Graph copy()
public Graph uniqueCopy()
x.getNodeList().get(0) != y.getNodeList().get(0) under any
circumstances. The Nodes and Edges may remain equivalent via the
equals() implementation. Further, Edge data shall remain entangled due
to implementation details.